#include "../ast.h"
#include "../token.h"
#include <memory>

std::unique_ptr<Expression> Expression::parseAST() {

  getNextToken();

  switch (currentType) {
  case Identifier:
    switch (strlen(currentValue.identifier)) {
    case 1:
      switch (currentValue.identifier[0]) {
      case '!':
      case '+':
      case '*':
      case '/':
        return UnaryExpression::parseAST();
        break;
      case '&':
      case '|':
      case '^':
        break;
      }
      break;
    default:
      return UnaryExpression::parseAST();
    }

    break;

  case Integer:
  case Number:
  case String:
    return 0;
    break;
  case End:
    return 0;
    break;
  }
}

std::unique_ptr<UnaryExpression> UnaryExpression::parseAST() {
  char *type = currentValue.identifier;
  auto node = Expression::parseAST();

  return std::make_unique<UnaryExpression>(type, std::move(node));
}

std::unique_ptr<BinaryExpression>
BinaryExpression::parseAST(std::unique_ptr<Expression> left) {
  char *type = currentValue.identifier;
  auto right = Expression::parseAST();

  return std::make_unique<BinaryExpression>(type, std::move(left),
                                            std::move(right));
}
